package cn.com.nr.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import cn.com.common.constants.Constants;
import cn.com.common.result.DataResult;
import cn.com.nr.entity.NrConcreteEndangerEntity;
import cn.com.nr.entity.NrDiggingsEndangerEntity;
import cn.com.nr.entity.NrOfflineCamEntity;
import cn.com.nr.service.NrConcreteEndangerService;
import cn.com.nr.service.NrDiggingsEndangerService;
import cn.com.nr.service.NrOfflineCamService;
import cn.com.system.entity.SysDept;
import cn.com.system.service.DeptService;
import cn.com.system.service.impl.HttpSessionService;
import cn.com.util.TsBqUtils;



/**
 * 离线摄像头监控
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2025-04-02 17:05:05
 */
@Controller
@RequestMapping("/nr/offlinecam")
public class NrOfflineCamController {
    @Autowired
    private NrOfflineCamService nrOfflineCamService;
    @Autowired
    private HttpSessionService httpSessionService;
    @Autowired
    private NrDiggingsEndangerService diggingsEndangerService;
    @Autowired
    private NrConcreteEndangerService concreteEndangerService;
    @Autowired
    private DeptService deptService;
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "采矿-查询分页数据")
    @PostMapping("/oreCollectList0")
    @ResponseBody
    public DataResult oreCollectList0(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException{
    	
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		String taxorgcode = nrOfflineCam.getTaxorgcode();
		
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if (TsBqUtils.isNotNull(name)) {
			LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.like(NrDiggingsEndangerEntity::getName, name);
			queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿采矿");
			List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
			
			for (NrDiggingsEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
			
		}else{
			LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿采矿");
			
			List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
			for (NrDiggingsEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}
		
		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		QueryWrapper<NrOfflineCamEntity> queryWrapper = new QueryWrapper<>();

		LambdaQueryWrapper<NrOfflineCamEntity> lambdaQueryWrapper = queryWrapper
				.select("count(1) AS value,station_name as stationName,taxorg_name as taxorgName").lambda()
				.groupBy(NrOfflineCamEntity::getStationName)
				.groupBy(NrOfflineCamEntity::getTaxorgName);
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			lambdaQueryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if(TsBqUtils.isNotNull(taxorgcode)){
			lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, taxorgcode);
			
		}else{
			if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 县区局
				lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
			} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 市局 
				lambdaQueryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
			}else{
				// 省局
			}
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			lambdaQueryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			lambdaQueryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, lambdaQueryWrapper);
		
		
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity entity : records) {
			String taxorgName = entity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				entity.setTaxorgName(sysDept.getName());
			}

			String stationName = entity.getStationName();
			NrDiggingsEndangerEntity stationinfo = diggingsEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(stationinfo)) {
				entity.setStationName(stationinfo.getName());
			}
		}
		return DataResult.success(iPage);
    }
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "选矿-查询分页数据")
    @PostMapping("/oreSelectList0")
    @ResponseBody
    public DataResult oreSelectList0(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException{
    	
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		String taxorgcode = nrOfflineCam.getTaxorgcode();
		
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if (TsBqUtils.isNotNull(name)) {
			LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.like(NrDiggingsEndangerEntity::getName, name);
			queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿选矿");
			List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
			
			for (NrDiggingsEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
			
		}else{
			LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿选矿");
			
			List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
			for (NrDiggingsEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}
		
		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		QueryWrapper<NrOfflineCamEntity> queryWrapper = new QueryWrapper<>();

		LambdaQueryWrapper<NrOfflineCamEntity> lambdaQueryWrapper = queryWrapper
				.select("count(1) AS value,station_name as stationName,taxorg_name as taxorgName").lambda()
				.groupBy(NrOfflineCamEntity::getStationName)
				.groupBy(NrOfflineCamEntity::getTaxorgName);
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			lambdaQueryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if(TsBqUtils.isNotNull(taxorgcode)){
			lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, taxorgcode);
			
		}else{
			if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 县区局
				lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
			} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 市局 
				lambdaQueryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
			}else{
				// 省局
			}
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			lambdaQueryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			lambdaQueryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, lambdaQueryWrapper);
		
		
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity entity : records) {
			String taxorgName = entity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				entity.setTaxorgName(sysDept.getName());
			}

			String stationName = entity.getStationName();
			NrDiggingsEndangerEntity stationinfo = diggingsEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(stationinfo)) {
				entity.setStationName(stationinfo.getName());
			}
		}
		return DataResult.success(iPage);
    }
    
    @SuppressWarnings("unchecked")
	@ApiOperation(value = "水泥制造-查询分页数据")
    @PostMapping("/cementList0")
    @ResponseBody
    public DataResult cementList0(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException{
    	

    	
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		String taxorgcode = nrOfflineCam.getTaxorgcode();
		
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if (TsBqUtils.isNotNull(name)) {
			LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.like(NrConcreteEndangerEntity::getName, name);
			queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "水泥制造");
			List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
			
			for (NrConcreteEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
			
		}else{
			LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "水泥制造");
			
			List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
			for (NrConcreteEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}
		
		@SuppressWarnings("rawtypes")
		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		QueryWrapper<NrOfflineCamEntity> queryWrapper = new QueryWrapper<>();

		LambdaQueryWrapper<NrOfflineCamEntity> lambdaQueryWrapper = queryWrapper
				.select("count(1) AS value,station_name as stationName,taxorg_name as taxorgName").lambda()
				.groupBy(NrOfflineCamEntity::getStationName)
				.groupBy(NrOfflineCamEntity::getTaxorgName);
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			lambdaQueryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if(TsBqUtils.isNotNull(taxorgcode)){
			lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, taxorgcode);
			
		}else{
			if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 县区局
				lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
			} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 市局 
				lambdaQueryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
			}else{
				// 省局
			}
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			lambdaQueryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			lambdaQueryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, lambdaQueryWrapper);
		
		
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity entity : records) {
			String taxorgName = entity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				entity.setTaxorgName(sysDept.getName());
			}

			String stationName = entity.getStationName();
			NrConcreteEndangerEntity stationinfo = concreteEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(stationinfo)) {
				entity.setStationName(stationinfo.getName());
			}
		}
		return DataResult.success(iPage);
    	
    }
    
    @SuppressWarnings("unchecked")
	@ApiOperation(value = "混凝土-查询分页数据")
    @PostMapping("/concreteList0")
    @ResponseBody
    public DataResult concreteList0(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException{
    	

    	
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		String taxorgcode = nrOfflineCam.getTaxorgcode();
		
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if (TsBqUtils.isNotNull(name)) {
			LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.like(NrConcreteEndangerEntity::getName, name);
			queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "混凝土");
			List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
			
			for (NrConcreteEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
			
		}else{
			LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "混凝土");
			
			List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
			for (NrConcreteEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}
		
		@SuppressWarnings("rawtypes")
		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		QueryWrapper<NrOfflineCamEntity> queryWrapper = new QueryWrapper<>();

		LambdaQueryWrapper<NrOfflineCamEntity> lambdaQueryWrapper = queryWrapper
				.select("count(1) AS value,station_name as stationName,taxorg_name as taxorgName").lambda()
				.groupBy(NrOfflineCamEntity::getStationName)
				.groupBy(NrOfflineCamEntity::getTaxorgName);
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			lambdaQueryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if(TsBqUtils.isNotNull(taxorgcode)){
			lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, taxorgcode);
			
		}else{
			if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 县区局
				lambdaQueryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
			} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
				// 市局 
				lambdaQueryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
			}else{
				// 省局
			}
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			lambdaQueryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			lambdaQueryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, lambdaQueryWrapper);
		
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity entity : records) {
			String taxorgName = entity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				entity.setTaxorgName(sysDept.getName());
			}

			String stationName = entity.getStationName();
			NrConcreteEndangerEntity stationinfo = concreteEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(stationinfo)) {
				entity.setStationName(stationinfo.getName());
			}
		}
		return DataResult.success(iPage);
    }
    
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "采矿-查询分页数据")
	@PostMapping("/oreCollectList")
	@ResponseBody
	public DataResult oreCollectList(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		String currentDeptId = httpSessionService.getCurrentDeptId();

		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if(TsBqUtils.isNotNull(nrOfflineCam.getStationId())){
			
			LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrDiggingsEndangerEntity::getName, nrOfflineCam.getStationId());
			queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿采矿");
			List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
			for (NrDiggingsEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}else{
			if (TsBqUtils.isNotNull(name)) {
				LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
				queryStationinfo.like(NrDiggingsEndangerEntity::getName, name);
				queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿采矿");
				List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
				for (NrDiggingsEndangerEntity entity : list) {
					String id = entity.getId();
					stationinfoId.add(id);
				}
			}
		}

		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		LambdaQueryWrapper<NrOfflineCamEntity> queryWrapper = Wrappers.lambdaQuery();
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			queryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 县区局
			queryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
		} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 市局
			queryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
		}else{
			// 省局
		}

		// 查询条件示例
		if (TsBqUtils.isNotNull(nrOfflineCam.getCamId())) {
			queryWrapper.eq(NrOfflineCamEntity::getCamId, nrOfflineCam.getCamId());
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			queryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			queryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, queryWrapper);
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity nrOfflineCamEntity : records) {
			String taxorgName = nrOfflineCamEntity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				nrOfflineCamEntity.setTaxorgName(sysDept.getName());
			}

			String stationName = nrOfflineCamEntity.getStationName();
			NrDiggingsEndangerEntity diggingsEndangerEntity = diggingsEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(diggingsEndangerEntity)) {
				nrOfflineCamEntity.setStationName(diggingsEndangerEntity.getName());
			}

		}

		return DataResult.success(iPage);
	}
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "选矿-查询分页数据")
	@PostMapping("/oreSelectList")
	@ResponseBody
	public DataResult oreSelectList(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		String currentDeptId = httpSessionService.getCurrentDeptId();

		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if(TsBqUtils.isNotNull(nrOfflineCam.getStationId())){
			
			LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrDiggingsEndangerEntity::getName, nrOfflineCam.getStationId());
			queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿选矿");
			List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
			for (NrDiggingsEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}else{
			if (TsBqUtils.isNotNull(name)) {
				LambdaQueryWrapper<NrDiggingsEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
				queryStationinfo.like(NrDiggingsEndangerEntity::getName, name);
				queryStationinfo.eq(NrDiggingsEndangerEntity::getIndustry, "铁矿选矿");
				List<NrDiggingsEndangerEntity> list = diggingsEndangerService.list(queryStationinfo);
				for (NrDiggingsEndangerEntity entity : list) {
					String id = entity.getId();
					stationinfoId.add(id);
				}
			}
		}

		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		LambdaQueryWrapper<NrOfflineCamEntity> queryWrapper = Wrappers.lambdaQuery();
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			queryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 县区局
			queryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
		} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 市局
			queryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
		}else{
			// 省局
		}

		// 查询条件示例
		if (TsBqUtils.isNotNull(nrOfflineCam.getCamId())) {
			queryWrapper.eq(NrOfflineCamEntity::getCamId, nrOfflineCam.getCamId());
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			queryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			queryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, queryWrapper);
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity nrOfflineCamEntity : records) {
			String taxorgName = nrOfflineCamEntity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				nrOfflineCamEntity.setTaxorgName(sysDept.getName());
			}

			String stationName = nrOfflineCamEntity.getStationName();
			NrDiggingsEndangerEntity diggingsEndangerEntity = diggingsEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(diggingsEndangerEntity)) {
				nrOfflineCamEntity.setStationName(diggingsEndangerEntity.getName());
			}

		}

		return DataResult.success(iPage);
	}  
    
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "水泥制造-查询分页数据")
	@PostMapping("/cementList")
	@ResponseBody
	public DataResult cementList(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		String currentDeptId = httpSessionService.getCurrentDeptId();

		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if(TsBqUtils.isNotNull(nrOfflineCam.getStationId())){
			
			LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrConcreteEndangerEntity::getName, nrOfflineCam.getStationId());
			queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "水泥制造");
			List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
			for (NrConcreteEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}else{
			if (TsBqUtils.isNotNull(name)) {
				LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
				queryStationinfo.like(NrConcreteEndangerEntity::getName, name);
				queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "水泥制造");
				List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
				for (NrConcreteEndangerEntity entity : list) {
					String id = entity.getId();
					stationinfoId.add(id);
				}
			}
		}

		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		LambdaQueryWrapper<NrOfflineCamEntity> queryWrapper = Wrappers.lambdaQuery();
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			queryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 县区局
			queryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
		} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 市局
			queryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
		}else{
			// 省局
		}

		// 查询条件示例
		if (TsBqUtils.isNotNull(nrOfflineCam.getCamId())) {
			queryWrapper.eq(NrOfflineCamEntity::getCamId, nrOfflineCam.getCamId());
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			queryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			queryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, queryWrapper);
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity nrOfflineCamEntity : records) {
			String taxorgName = nrOfflineCamEntity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				nrOfflineCamEntity.setTaxorgName(sysDept.getName());
			}

			String stationName = nrOfflineCamEntity.getStationName();
			NrConcreteEndangerEntity nrConcreteEndangerEntity = concreteEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(nrConcreteEndangerEntity)) {
				nrOfflineCamEntity.setStationName(nrConcreteEndangerEntity.getName());
			}

		}

		return DataResult.success(iPage);
	}
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "混凝土-查询分页数据")
	@PostMapping("/concreteList")
	@ResponseBody
	public DataResult concreteList(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		String currentDeptId = httpSessionService.getCurrentDeptId();

		String name = nrOfflineCam.getStationName();
		
		List<String> stationinfoId = new ArrayList<>();
		if(TsBqUtils.isNotNull(nrOfflineCam.getStationId())){
			
			LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
			queryStationinfo.eq(NrConcreteEndangerEntity::getName, nrOfflineCam.getStationId());
			queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "混凝土");
			List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
			for (NrConcreteEndangerEntity entity : list) {
				String id = entity.getId();
				stationinfoId.add(id);
			}
		}else{
			if (TsBqUtils.isNotNull(name)) {
				LambdaQueryWrapper<NrConcreteEndangerEntity> queryStationinfo = Wrappers.lambdaQuery();
				queryStationinfo.like(NrConcreteEndangerEntity::getName, name);
				queryStationinfo.eq(NrConcreteEndangerEntity::getIndustry, "混凝土");
				List<NrConcreteEndangerEntity> list = concreteEndangerService.list(queryStationinfo);
				for (NrConcreteEndangerEntity entity : list) {
					String id = entity.getId();
					stationinfoId.add(id);
				}
			}
		}

		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		LambdaQueryWrapper<NrOfflineCamEntity> queryWrapper = Wrappers.lambdaQuery();
		
		if (TsBqUtils.isNotNull(stationinfoId)) {
			queryWrapper.in(NrOfflineCamEntity::getStationName, stationinfoId);
		}else{
			return DataResult.fail("暂无数据！");
		}
		
		if (Constants.TAX_COUNTES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 县区局
			queryWrapper.eq(NrOfflineCamEntity::getTaxorgName, currentDeptId);
		} else if (Constants.TAX_CITIES.equals(TsBqUtils.getTaxOrgLevel(currentDeptId))) {
			// 市局
			queryWrapper.like(NrOfflineCamEntity::getTaxorgName, currentDeptId.substring(0, 5));
		}else{
			// 省局
		}

		// 查询条件示例
		if (TsBqUtils.isNotNull(nrOfflineCam.getCamId())) {
			queryWrapper.eq(NrOfflineCamEntity::getCamId, nrOfflineCam.getCamId());
		}
		
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeStart())) {
			queryWrapper.ge(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeStart() + " 00:00:00"));
		}
		if (!StringUtils.isEmpty(nrOfflineCam.getCreateTimeEnd())) {
			queryWrapper.le(NrOfflineCamEntity::getOfflineTime, sdf.parse(nrOfflineCam.getCreateTimeEnd() + " 23:59:59"));
		}
		
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, queryWrapper);
		List<NrOfflineCamEntity> records = iPage.getRecords();

		for (NrOfflineCamEntity nrOfflineCamEntity : records) {
			String taxorgName = nrOfflineCamEntity.getTaxorgName();
			SysDept sysDept = deptService.getById(taxorgName);
			if (TsBqUtils.isNotNull(sysDept)) {
				nrOfflineCamEntity.setTaxorgName(sysDept.getName());
			}

			String stationName = nrOfflineCamEntity.getStationName();
			NrConcreteEndangerEntity nrConcreteEndangerEntity = concreteEndangerService.getById(stationName);
			if (TsBqUtils.isNotNull(nrConcreteEndangerEntity)) {
				nrOfflineCamEntity.setStationName(nrConcreteEndangerEntity.getName());
			}

		}

		return DataResult.success(iPage);
	}
    
}
